package com.basic.common.utils;

import cn.hutool.core.util.ObjectUtil;
import com.basic.common.exception.RRException;
import com.basic.modules.sys.entity.SysUserEntity;
import org.apache.shiro.SecurityUtils;

public class CommonUtils {

    public static SysUserEntity getUser(){
        Object principal = SecurityUtils.getSubject().getPrincipal();
        if (ObjectUtil.isEmpty(principal)) {
            throw new RRException("获取当前登录用户失败，请检查");
        }
        return (SysUserEntity) principal;
    }

    public static Long getUserId(){
        return getUser().getUserId();
    }
}
